/**
  ******************************************************************************
  * @file    app_acad.h
  * @author  Sherlock
  * @version V0.1
  * @date    07/31/2024
  * @brief   Initial all Periphs
  ******************************************************************************
  * @copy
  *
  * <h2><center>&copy; COPYRIGHT 2010 Feirui</center></h2>
  */ 

#ifndef  __APP_ACAD_H__
#define  __APP_ACAD_H__

#ifdef __cplusplus
 extern "C" {
#endif

#define OSACADFlags_Measure                        ((OS_FLAGS)DEF_BIT_00)
#define OSACADFlags_Timing                         ((OS_FLAGS)DEF_BIT_01)

#define OSACADFlags_ALL                            (OSACADFlags_Measure|OSACADFlags_Timing)
#define OSACADFlags_DefaultValue                   ((OS_FLAGS)0x00000000)

/**
  * @brief GLOBALS RAM definition
  */
//#define APP_ACAD_START
#ifdef   APP_GLOBALS_ACAD
#define  APP_EXT_ACAD
#else
#define  APP_EXT_ACAD  extern
#endif


/* OS_Q */
#define ACADRecdataQNum        9  /* equ NumOfACRXdataQ */
typedef struct
{
  uint8_t  RawData;
  uint8_t  InputType;
} AC_Receivedata_TypeDef;
APP_EXT_ACAD AC_Receivedata_TypeDef ACRXdataTempBuffer[ACADRecdataQNum];
#define ADCRecDataType_Null    0
#define ADCRecDataType_Full    1


/************************************************************************************/
/* Raw Data, 全局数据 */
typedef struct
{
  float GenPhaseVoltL1;      //相电压
  float GenPhaseVoltL2;
  float GenPhaseVoltL3;
  float GenPhaseVoltAverage;
  float GenLineVoltL12;      //线电压
  float GenLineVoltL23;
  float GenLineVoltL31;
  float GenLineVoltAverage;
  float GenFreqL12;          //发电频率
  float GenFreqL23;
  float GenFreqL31;
  float GenFreqAverage;
  float GenPhaseDiffU2U1;    //电压相序相位差
  float GenPhaseDiffU3U1;
} ACAD_GeneratorDataTypeDef;

typedef struct
{
  float ExcitationVolt;        //励磁电压
  float ExcitationCurr;        //励磁电流
  float ExcitationPower;        //励磁功率
} ACAD_ExcitationDataTypeDef;


typedef struct
{
  float VoltDiffU1;         //合闸电压差
  float VoltDiffU2;
  float VoltDiffU3;
  float VoltDiffAverage;
  float PhaseDiffU1;        //合闸相位差
  float PhaseDiffU2;
  float PhaseDiffU3;
  float PhaseDiffAverage;
  float SyncErrU1;
  float SyncErrU2;
  float SyncErrU3;
  float SyncErrAverage;
} ACAD_SynchronousDataTypeDef;

typedef struct
{
  float GenCurrL1;         //发电电流
  float GenCurrL2;
  float GenCurrL3;
  float GenCurrLAverage;
  float GenPowerP1;        //有功功率
  float GenPowerP2;
  float GenPowerP3;
  float GenPowerPTotal;
  float GenPowerQ1;        //无功功率
  float GenPowerQ2;
  float GenPowerQ3;
  float GenPowerQTotal;
  float GenPowerS1;        //视在功率
  float GenPowerS2;
  float GenPowerS3;
  float GenPowerSTotal;
  float GenPFL1;           //功率因数
  float GenPFL2;
  float GenPFL3;
  float GenPFAverage;
} ACAD_PowerDataTypeDef;

typedef struct
{
  float BuildVoltFreq;   //建磁频率
  float BuildVoltBEF;    //建磁电压（前）
  float BuildVoltAFT;    //建磁电压（后）
} ACAD_BuildVoltDataTypeDef;

typedef struct
{
  ACAD_GeneratorDataTypeDef LoadVoltData;        //负载电机发电数据
  ACAD_ExcitationDataTypeDef LoadExcitationData; //负载电机励磁数据
  ACAD_GeneratorDataTypeDef GenVoltData;         //被测电机发电数据
  ACAD_ExcitationDataTypeDef GenExcitationData;  //被测电机励磁数据
  ACAD_SynchronousDataTypeDef SyncData;          //合闸数据
  ACAD_PowerDataTypeDef PowerData;               //功率数据
  ACAD_BuildVoltDataTypeDef BuildVoltData;       //建压数据
} ACAD_RTDataTypeDef;

APP_EXT_ACAD ACAD_RTDataTypeDef ACAD_RTGlobalData;   //全局测算数据，随取随用

/************************************************************************************/



/**
  * @brief Functions
  */
void InitGovSyncErr();




#ifdef __cplusplus
}
#endif


#endif   /*   __APP_ACAD_H__   */